<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>日志</title>
    <link href="../../component/pear/css/pear.css" rel="stylesheet"/>
</head>
<body class="pear-container">
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">关键字</label>
                <div class="layui-input-inline">
                    <input type="text" name="keyWord" placeholder="" class="layui-input">
                </div>
                <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="query">
                    <i class="layui-icon layui-icon-search"></i>
                    查询
                </button>
                <button type="reset" class="pear-btn pear-btn-md">
                    <i class="layui-icon layui-icon-refresh"></i>
                    重置
                </button>
            </div>
        </form>
    </div>
</div>
<div class="layui-card">
    <div class="layui-card-body">
        <table id="table" lay-filter="table-filter"></table>
    </div>
</div>

</body>

<script type="text/html" id="record-toolbar">
    <button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit">
        <i class="layui-icon layui-icon-edit"></i>
    </button>
    <button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove">
        <i class="layui-icon layui-icon-delete"></i>
    </button>
</script>

<script type="text/html" id="table-toolbar">
    <button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
        <i class="layui-icon layui-icon-add-1"></i>
        新增
    </button>
    <button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove">
        <i class="layui-icon layui-icon-delete"></i>
        删除
    </button>
</script>
<script type="text/html" id="log-bar">
    {{#if (d.status) { }}
    <button class="pear-btn pear-btn-sm pear-btn-success">
        成功
    </button>
    {{# }else if(!d.status){ }}
    <button class="pear-btn pear-btn-sm pear-btn-danger">
        异常
    </button>
    {{# } }}
</script>

<script src="../../component/layui/layui.js"></script>
<script src="../../component/pear/pear.js"></script>
<script>
    layui.use(['easyAdmin'], function () {
        let easyAdmin = layui.easyAdmin;

        let cols = [
                [
                    {
                        title: '用户',
                        field: 'user.nickName',
                        align: 'center',
                        width: 80,
                        templet: function (d) {
                            if (d.user != null) {
                                return d.user.nickName;
                            } else {
                                return "";
                            }
                        }
                    },
                    {
                        title: '部门',
                        field: 'DeptName',
                        align: 'center',
                        width: 80,
                        templet: function (d) {
                            if (d.user != null && d.user.dept != null) {
                                return d.user.dept.deptName;
                            } else {
                                return "";
                            }
                        }
                    },
                    {
                        title: '城市',
                        field: 'city',
                        align: 'center',
                        width: 140
                    },
                    {
                        title: '请求URI',
                        field: 'uri',
                        align: 'center',
                        width: 160
                    },
                    {
                        title: 'Client',
                        field: 'client',
                        align: 'center',
                        width: 300
                    },
                    {
                        title: '请求IP',
                        field: 'ip',
                        align: 'center',
                        width: 100
                    },
                    {
                        title: '请求内容',
                        field: 'request',
                        align: 'center',
                        width: 100
                    },
                    {
                        title: '响应内容',
                        field: 'response',
                        align: 'center',
                        width: 80
                    },
                    {
                        title: '耗时ms',
                        field: 'cost',
                        align: 'center',
                        width: 70
                    },
                    {
                        title: '访问时间',
                        field: 'createTime',
                        align: 'center',
                        width: 160
                    }
                    ,
                    {
                        title: '访问状态',
                        field: 'status',
                        align: 'center',
                        width: 80,
                        templet: '#log-bar'
                    }
                ]
            ]
        ;


        let module = "log";
        let uri = "/ext/" + module;
        easyAdmin.tableRender({
            url: uri,
            cols: cols,
            toolbar: null,
            defaultToolbar: null
        });
        easyAdmin.TableTool(uri, module);
        easyAdmin.TableToolBar(uri, module);
        easyAdmin.FormQuery();
    })
</script>
</html>
